package com.example.tass.domain;

import cn.tass.SRJ1933.devices.utis.StringUtils;
import cn.tass.exceptions.TAException;

public class MyBaseSymRequest extends MyBaseRequest{
    protected String keyId;
    protected String keyAccessCode;
    protected String extKeyInfo;
    protected String extKeyInfoAlg;
    protected String encKeyId;
    protected String enckeyAccessCode;
    protected int encMode;
    protected int encPadMode;
    protected String encIv;
    protected int mode;
    protected int padMode;
    protected String iv;

    public MyBaseSymRequest() {
    }

    public String getKeyId() {
        return this.keyId;
    }

    public void setKeyId(String keyId) {
        this.keyId = keyId;
    }

    public String getKeyAccessCode() {
        return this.keyAccessCode;
    }

    public void setKeyAccessCode(String keyAccessCode) {
        this.keyAccessCode = keyAccessCode;
    }

    public String getExtKeyInfo() {
        return this.extKeyInfo;
    }

    public String getExtKeyInfoAlg() {
        return this.extKeyInfoAlg;
    }

    public void setExtKeyInfoAlg(String extKeyInfoAlg) {
        this.extKeyInfoAlg = extKeyInfoAlg;
    }

    public void setExtKeyInfo(String extKeyInfo) {
        this.extKeyInfo = extKeyInfo;
    }

    public String getEncKeyId() {
        return this.encKeyId;
    }

    public void setEncKeyId(String encKeyId) {
        this.encKeyId = encKeyId;
    }

    public String getEnckeyAccessCode() {
        return this.enckeyAccessCode;
    }

    public void setEnckeyAccessCode(String enckeyAccessCode) {
        this.enckeyAccessCode = enckeyAccessCode;
    }

    public int getEncMode() {
        return this.encMode;
    }

    public void setEncMode(int encMode) {
        this.encMode = encMode;
    }

    public int getEncPadMode() {
        return this.encPadMode;
    }

    public void setEncPadMode(int encPadMode) {
        this.encPadMode = encPadMode;
    }

    public String getEncIv() {
        return this.encIv;
    }

    public void setEncIv(String encIv) {
        this.encIv = encIv;
    }

    public int getMode() {
        return this.mode;
    }

    public void setMode(int mode) {
        this.mode = mode;
    }

    public int getPadMode() {
        return this.padMode;
    }

    public void setPadMode(int padMode) {
        this.padMode = padMode;
    }

    public String getIv() {
        return this.iv;
    }

    public void setIv(String iv) {
        this.iv = iv;
    }

    public void validate() throws TAException {
        if (StringUtils.isEmpty(this.keyId) && StringUtils.isEmpty(this.extKeyInfo)) {
            throw new TAException("Must set either keyId or extKeyInfo", new Object[]{""});
        } else if (!StringUtils.isEmpty(this.extKeyInfo) && StringUtils.isEmpty(this.extKeyInfoAlg)) {
            throw new TAException("When setting the extKeyInfo parameter, you must set extKeyInfoAlg.", new Object[]{""});
        } else if (!StringUtils.isEmpty(this.encKeyId) && this.encMode != 0 && StringUtils.isEmpty(this.encIv)) {
            throw new TAException("When the key is encript text and not ECB mode, the encIv parameter must be set to.", new Object[]{""});
        } else if (this.mode != 0 && StringUtils.isEmpty(this.iv)) {
            throw new TAException("When mode not ECB mode, the iv parameter must be set to.", new Object[]{""});
        }
    }
}
